
package com.xbongbong.pro.statistic.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.pro.domain.dao.ChartLimitDao;
import com.xbongbong.pro.domain.entity.ChartLimitEntity;
import com.xbongbong.pro.statistic.model.ChartLimitModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * @ClassName ChartLimitModelImpl
 * @Description 图表限制
 * @Author mengna.Deng
 * @Date 2021/8/23 14:47
 * @Version 1.0
 */
@Service("chartLimitModel")
public class ChartLimitModelImpl implements ChartLimitModel {

	@Resource
	private ChartLimitDao chartLimitDao;

	@Override
	public Integer insert(ChartLimitEntity entity) throws XbbException {
		long now = DateUtil.getInt();
		entity.setAddTime(now);
		entity.setUpdateTime(now);
		Integer insert = chartLimitDao.insert(entity);
		//TODO  返回实体id
		return insert;
	}

	@Override
	public Integer update(ChartLimitEntity entity) throws XbbException {
		entity.setUpdateTime((long)DateUtil.getInt());
		//TODO  返回实体id
		return chartLimitDao.update(entity);
	}
	
	@Override
	public Integer updateDel(ChartLimitEntity entity) throws XbbException {
		entity.setUpdateTime((long)DateUtil.getInt());
		//TODO  返回实体id
		return chartLimitDao.update(entity);
	}

	@Override
	public List<ChartLimitEntity> findEntitys(Map<String, Object> param) {
		return chartLimitDao.findEntitys(param);
	}

	@Override
	public Integer getEntitysCount(Map<String, Object> param) {
		return chartLimitDao.getEntitysCount(param);
	}

	@Override
	public List findEntitysWithoutSub(Map<String, Object> param) {
		return null;
	}

	@Override
	public Integer save(ChartLimitEntity entity) throws XbbException {
		if(entity.getId() == null || entity.getId().equals(0L)) {
			return insert(entity);
		}
		return update(entity);
	}

	@Override
	public void insertBatch(List<ChartLimitEntity> entityList) {
		chartLimitDao.insertBatch(entityList);
	}

	@Override
	public Integer deleteByKey(Long key, String corpid) {
		return chartLimitDao.deleteByKey(key, corpid);
	}

	@Override
	public ChartLimitEntity getByKey(Long key, String corpid) {
		return chartLimitDao.getByKey(key, corpid);
	}

	@Override
	public void updateBatch(List<ChartLimitEntity> chartLimitEntityList, String corpid) {
		chartLimitDao.updateBatch(chartLimitEntityList, corpid);
	}

	@Override
	public ChartLimitEntity getByType(Integer type, String corpid) {
		return chartLimitDao.getByType(type,corpid);
	}

	@Override
	public ChartLimitEntity getByAlias(String alias, String corpid) {
		return chartLimitDao.getByAlias(alias,corpid);
	}
}

